package com.base.factory.abstructfactory;


import com.base.factory.abstructfactory.factory.ComputerFactory;
import com.base.factory.abstructfactory.factory.DefaultAbstructFactory;
import com.base.factory.abstructfactory.factory.impl.AsusFactory;
import com.base.factory.abstructfactory.service.ComputerService;

/**
 * Created by xingyuchao on 2017-06-17.
 * 测试抽象工厂
 */
public class Main {
    public static void main(String[] args) {

        //Spring中的工厂模式也是这样，通过一个getBean 来获取一下各种bean
        //Bean
        //BeanFactory（生成Bean）
        //单例的Bean
        //被代理过的Bean
        //最原始的Bean（原型）
        //List类型的Bean
        //作用域不同的Bean

        //getBean
        //非常的紊乱，维护困难
        //解耦（松耦合开发）

       /* ComputerFactory computerFactory = new ComputerFactory() {
            @Override
            public ComputerService getComputer() {
                return new AsusFactory().getComputer();
            }
        };
        ComputerService ComputerService = computerFactory.getComputer();
        System.out.println(ComputerService.getBrand());
        ComputerService = computerFactory.getComputer("Dell");
        System.out.println(ComputerService.getBrand());*/


        DefaultAbstructFactory defaultAbstructFactory = new DefaultAbstructFactory();
        ComputerService computer = defaultAbstructFactory.getComputer();
        System.out.println(computer.getBrand());
        computer = defaultAbstructFactory.getComputer("ThinkPad");
        System.out.println(computer.getBrand());
    }
}
